/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package calibracaolion;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Santi
 */
@Entity
@Table(name = "familia", catalog = "geins", schema = "")
@NamedQueries({
    @NamedQuery(name = "Familia.findAll", query = "SELECT f FROM Familia f"),
    @NamedQuery(name = "Familia.findByCodFamilia", query = "SELECT f FROM Familia f WHERE f.codFamilia = :codFamilia"),
    @NamedQuery(name = "Familia.findByFamilia", query = "SELECT f FROM Familia f WHERE f.familia = :familia")})
public class Familia implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "cod_familia")
    private Integer codFamilia;
    @Basic(optional = false)
    @Column(name = "familia")
    private String familia;
    @OneToMany(mappedBy = "codFamilia")
    private List<Instrumentos> instrumentosList;

    public Familia() {
    }

    public Familia(Integer codFamilia) {
        this.codFamilia = codFamilia;
    }

    public Familia(Integer codFamilia, String familia) {
        this.codFamilia = codFamilia;
        this.familia = familia;
    }

    public Integer getCodFamilia() {
        return codFamilia;
    }

    public void setCodFamilia(Integer codFamilia) {
        Integer oldCodFamilia = this.codFamilia;
        this.codFamilia = codFamilia;
        changeSupport.firePropertyChange("codFamilia", oldCodFamilia, codFamilia);
    }

    public String getFamilia() {
        return familia;
    }

    public void setFamilia(String familia) {
        String oldFamilia = this.familia;
        this.familia = familia;
        changeSupport.firePropertyChange("familia", oldFamilia, familia);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codFamilia != null ? codFamilia.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Familia)) {
            return false;
        }
        Familia other = (Familia) object;
        if ((this.codFamilia == null && other.codFamilia != null) || (this.codFamilia != null && !this.codFamilia.equals(other.codFamilia))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "calibracaolion.Familia[codFamilia=" + codFamilia + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
